<?php /* Smarty version 2.6.20, created on 2011-10-25 19:40:30
         compiled from _core/_include/module/_mvc/control/handlesearchmail.tpl */ ?>
function HandleSearchMail(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  this._popupBox = new PopupBox();

  this._callbackFunc = (options && options.callbackFunc) ? options.callbackFunc : function() {};
  this._query = (options && options.query) ? options.query : '1=1';

  this._createElements();
}

HandleSearchMail.prototype._createElements = function() {
  var _self = this;
  this._gui.mailNo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                              if (code == 13) {
                                                _self._callbackFunc(escape(((_self._gui.mailNo.value != '') ? 'd.code LIKE \'%' + _self._gui.mailNo.value + '%\'' : '1=1') + ' AND ' + ((_self._gui.customerNo.value != '') ? 'd.customerId = \'' + _self._gui.customerNo.value + '\'' : '1 = 1') + ' AND ' + ((_self._gui.product.value != '') ? 'd.title LIKE \'%' + _self._gui.product.value + '%\'' : '1 = 1')));
                                              }
                                            };
  this._gui.mailNo.onkeyup = function() { if (_self._gui.mailNo.value.length == 0) {
                                            _self._popupBox._close();
                                          } else {
                                            var div = document.createElement('div');
                                            var pos1 = DOMUtils.findPos(_self._gui.mailNo);
                                            var pos = [pos1[0], pos1[1] + 82];
                                            var query = "SELECT DISTINCT d.code FROM ns_Produce as d WHERE " + _self._query + " AND " + '((d.code LIKE \'%' + _self._gui.mailNo.value + '%\'))' + " ";
                                            MiscUtils.dialog(_self._popupBox, pos, div, null, null, {pop: true});
                                            new DialogSearchResult(div, _self._gui.mailNo, { query: query, popupBox: _self._popupBox, callbackFunc: function() { _self._createElements(); }, php: Constant.FACTORY + '/customphp/mysqlcustom.php', width: 110 });
                                          }
                                        };
  this._gui.customerNo.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                                  if (code == 13) {
                                                    _self._callbackFunc(escape(((_self._gui.mailNo.value != '') ? 'd.code LIKE \'%' + _self._gui.mailNo.value + '%\'' : '1=1') + ' AND ' + ((_self._gui.customerNo.value != '') ? 'd2.customerId = \'' + _self._gui.customerNo.value + '\'' : '1 = 1') + ' AND ' + ((_self._gui.product.value != '') ? 'd2.title LIKE \'%' + _self._gui.product.value + '%\'' : '1 = 1')));
                                                  }
                                                };
  this._gui.customerNo.onkeyup = function() { if (_self._gui.customerNo.value.length == 0) {
                                                _self._popupBox._close();
                                              } else {
                                                var div = document.createElement('div');
                                                var pos1 = DOMUtils.findPos(_self._gui.customerNo);
                                                var pos = [pos1[0] + 1, pos1[1] + 82];
                                                var query = "SELECT DISTINCT d2.customerId as customerId FROM ns_Produce as d LEFT JOIN ns_produce AS d2 ON d.trackId = d2.parent_trackId WHERE " + _self._query + " AND " + '((d2.customerId LIKE \'%' + _self._gui.customerNo.value + '%\'))' + " ";
                                                MiscUtils.dialog(_self._popupBox, pos, div, null, null, {pop: true});
                                                new DialogSearchResult(div, _self._gui.customerNo, { query: query, popupBox: _self._popupBox, callbackFunc: function() { _self._createElements();}, php: Constant.FACTORY + '/customphp/mysqlcustom.php', width: 110});
                                              }
                                            };
  this._gui.product.onkeypress = function(e) { var code = DOMUtils.getEventCode(e);
                                               if (code == 13) {
                                                 _self._callbackFunc(escape(((_self._gui.mailNo.value != '') ? 'd.code LIKE \'%' + _self._gui.mailNo.value + '%\'' : '1=1') + ' AND ' + ((_self._gui.customerNo.value != '') ? 'd2.customerId = \'' + _self._gui.customerNo.value + '\'' : '1 = 1') + ' AND ' + ((_self._gui.product.value != '') ? 'd2.title LIKE \'%' + _self._gui.product.value + '%\'' : '1 = 1')));
                                               }
                                             };
  this._gui.product.onkeyup = function(e) { if (_self._gui.product.value.length == 0) {
                                              _self._popupBox._close();
                                            } else {
                                              var div = document.createElement('div');
                                              var pos1 = DOMUtils.findPos(_self._gui.product);
                                              var pos = [pos1[0], pos1[1] + 82];
                                              var query = "SELECT DISTINCT d2.title FROM ns_Produce as d LEFT JOIN ns_produce AS d2 ON d.trackId = d2.parent_trackId WHERE " + _self._query + " AND " + '((d2.title LIKE \'%' + _self._gui.product.value + '%\'))' + " ";
                                              MiscUtils.dialog(_self._popupBox, pos, div, null, null, {pop: true});
                                              new DialogSearchResult(div, _self._gui.product, { query: query, popupBox: _self._popupBox, callbackFunc: function() { _self._createElements(); }, php: Constant.FACTORY + '/customphp/mysqlcustom.php', width: 110});
                                            }
                                          };
  this._gui.button.onclick = function() { _self._callbackFunc(escape(((_self._gui.mailNo.value != '') ? 'd.code LIKE \'%' + _self._gui.mailNo.value + '%\'' : '1=1') + ' AND ' + ((_self._gui.customerNo.value != '') ? 'd2.customerId = \'' + _self._gui.customerNo.value + '\'' : '1 = 1') + ' AND ' + ((_self._gui.product.value != '') ? 'd2.title LIKE \'%' + _self._gui.product.value + '%\'' : '1 = 1'))); };
};